/* 
 * Copyright (c) 2010 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.enterprise.gsa.uar;

import com.google.enterprise.gsa.PromotedResult;

/**
 * A wrapper class for a User Added Result (UAR)
 */
public class Uar extends PromotedResult {

  /* The username of who added the UAR */
  private String addedBy;
    
  /**
   * Create a UAR from the given information
   * 
   * @param query The query that triggers this UAR
   * @param url The URL that this UAR points to
   * @param title The descriptive title of the UAR
   * @param addedBy The author of the UAR
   */
  public Uar(String query, String url, String title, String addedBy){
    super(query, url, title);
    this.addedBy = addedBy;
  }
  
  /**
   * 
   * @return the author of the UAR
   */
  public String getAddedBy() {
    return addedBy;
  }

  /**
   * Sets the author of the UAR
   * 
   * @param addedBy the new author
   */
  public void setAddedBy(String addedBy) {
    this.addedBy = addedBy;
  }
  
  /**
   * A {@code String} in the format of
   * {@code Query/URL/Descriptive Title/Author}
   */
  @Override
  public String toString() {
    final char delim = '/';
    return getQuery() + delim + getUrl() + delim + getTitle() + delim + addedBy;
  }
  
} // End class Uar